<?php

class Damages_Methods_Response_GetDictionaries extends Damages_Methods_Response {

  /**
   *
   * @var Damages_Methods_Data_Dictionary_BrandsList 
   */
  public $brands;

  /**
   *
   * @var Damages_Methods_Data_Dictionary_DamageScalesList 
   */
  public $damageScales;

  /**
   *
   * @var Damages_Methods_Data_Dictionary_DamageSpotsList 
   */
  public $damageSpots;

  /**
   *
   * @var Damages_Methods_Data_Dictionary_DamageTypesList 
   */
  public $damageTypes;

  /**
   *
   * @var Damages_Methods_Data_Dictionary_DiscardsList 
   */
  public $discards;

  /**
   *
   * @var Damages_Methods_Data_Dictionary_NoteTypeDefinitionsList 
   */
  public $noteTypes;

  /**
   *
   * @var Damages_Methods_Data_Dictionary_PerpetratorsList 
   */
  public $perpetrators;

  /**
   *
   * @var Damages_Methods_Data_User[] 
   */
  public $ls = array();

  /**
   *
   * @var Damages_Methods_Data_Dictionary_StatusesList 
   */
  public $statuses;

  public function setData() {
    $this->setBrands();
    $this->setDamageScales();
    $this->setDamageSpots();
    $this->setDamageTypes();
    $this->setDiscards();
    $this->setNoteTypes();
    $this->setPerpetrators();
    $this->setStatuses();
    $this->setLs();
  }

  public function setBrands() {
    $data = DamagesDictBrandsQuery::create()
            ->filterByIsDeleted(0)
            ->leftJoinDictDiscounts()
            ->with('DictDiscounts')
            ->find();
    $this->brands = new Damages_Methods_Data_Dictionary_BrandsList($data);
  }

  public function setDamageScales() {
    $data = DamagesDictDamageScaleQuery::create()
            ->filterByIsDeleted(0)
            ->find();
    $this->damageScales = new Damages_Methods_Data_Dictionary_DamageScalesList($data);
  }

  public function setDamageSpots() {
    $data = DamagesDictDamageSpotsQuery::create()
            ->filterByIsDeleted(0)
            ->find();
    $this->damageSpots = new Damages_Methods_Data_Dictionary_DamageSpotsList($data);
  }

  public function setDamageTypes() {
    $data = DamagesDictDamageTypesQuery::create()
            ->filterByIsDeleted(0)
            ->find();
    $this->damageTypes = new Damages_Methods_Data_Dictionary_DamageTypesList($data);
  }

  public function setDiscards() {
    $data = DamagesDictDiscardsQuery::create()
            ->filterByIsDeleted(0)
            ->find();
    $this->discards = new Damages_Methods_Data_Dictionary_DiscardsList($data);
  }

  public function setNoteTypes() {
    $data = DamagesDictNoteTypeDefinitionsQuery::create()
            ->filterByIsDeleted(0)
            ->find();
    $this->noteTypes = new Damages_Methods_Data_Dictionary_NoteTypeDefinitionsList($data);
  }

  public function setPerpetrators() {
    $data = DamagesDictPerpetratorsQuery::create()
            ->filterByIsDeleted(0)
            ->find();
    $this->perpetrators = new Damages_Methods_Data_Dictionary_PerpetratorsList($data);
  }

  public function setLs() {
    $data = DamagesUsersQuery::create()
            ->usePermissionsQuery()
            ->filterByCode(Damages_Auth::PERMISSION_LS)
            ->endUse()
            ->find();
    foreach ($data as $user) {
      $this->ls[] = new Damages_Methods_Data_User($user, true);
    }
  }

  public function setStatuses() {
    $data = DamagesDictStatusesQuery::create()
            ->filterByIsDeleted(0)
            ->find();
    $this->statuses = new Damages_Methods_Data_Dictionary_StatusesList($data);
  }

}